home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / rules.cpp < prev    next >
C/C++ Source or Header  |  1996-03-07  |  65KB  |  2,979 lines

  1. /******************************************************************************
  2. *******************************************************************************
  3.  
  4. Match rules and control routines...
  5.  
  6. ******************************************************************************
  7. *****************************************************************************/
  8.  
  9. #include "global.h"
  10. #include "defines.h"
  11. #include "externs.h"
  12. #include "data.h"
  13. #include "audio.h"
  14.  
  15. #include "front.h"
  16. #include "eurofrnt\euro_int.h"
  17.  
  18. extern match_data match_info;
  19. extern team_info game_data[];
  20. extern setup_info setup;
  21. int timeout;
  22.  
  23. extern char old_tac_a,old_tac_b;
  24. extern void load_new_tactics();
  25.  
  26. /******************************************************************************
  27. *****************************************************************************/
  28.  
  29. void decide_set_kick()
  30. {
  31.     support_me=FALSE;
  32.     int p;
  33.  
  34.     switch(set_piece_on)
  35.     {
  36.         case(SETP_CORNER):
  37.             if (ref_wait<0)
  38.                 must_shoot=TRUE;
  39.             p=pass_decide(&teams[setp_taker-1],TRUE);
  40.             if (p)
  41.                 make_pass(&teams[setp_taker-1],p,TRUE);
  42.             else
  43.                 if (shoot_decide(&teams[setp_taker-1]))
  44.                     make_shoot(&teams[setp_taker-1]);
  45.                 else
  46.                     support_me=TRUE;        // No action (help).
  47.             break;
  48.  
  49.         case(SETP_CENTRE):
  50.             must_pass=TRUE;
  51.             p=centre_guy_2;
  52.             pass_type=5;
  53.             if (p)
  54.                 make_pass(&teams[setp_taker-1],p,FALSE);
  55.             else
  56.                 support_me=TRUE;        // No action (help).
  57.             must_pass=FALSE;
  58.             break;
  59.  
  60.         case(SETP_IFKICK):
  61.             if (ref_wait<0)
  62.                 must_punt=TRUE;
  63.             p=pass_decide(&teams[setp_taker-1],FALSE);
  64.             if (p)
  65.                 make_pass(&teams[setp_taker-1],p,FALSE);
  66.             else
  67.                 if (punt_decide(&teams[setp_taker-1]))
  68.                     make_punt(&teams[setp_taker-1]);
  69.                 else
  70.                     support_me=TRUE;        // No action (help).
  71.             break;
  72.  
  73.         case(SETP_GKICK):
  74.             if (ref_wait<0)
  75.                 must_punt=TRUE;
  76.             p=pass_decide(&teams[setp_taker-1],FALSE);
  77.             if (p && p!=KP_A && p!=KP_B)
  78.                 make_pass(&teams[setp_taker-1],p,FALSE);
  79.             else
  80.             {
  81.                 if (!seed&3)
  82.                     must_punt=TRUE;
  83.                 if (punt_decide(&teams[setp_taker-1]))
  84.                     make_punt(&teams[setp_taker-1]);
  85.                 else
  86.                     support_me=TRUE;        // No action (help).
  87.             }
  88.             break;
  89.  
  90.         case(SETP_DFKICK):
  91.             if (ref_wait<0)
  92.                 must_shoot=TRUE;
  93.             p=pass_decide(&teams[setp_taker-1],FALSE);
  94.             if (p)
  95.                 make_pass(&teams[setp_taker-1],p,FALSE);
  96.             else
  97.                 if (punt_decide(&teams[setp_taker-1]))
  98.                     make_punt(&teams[setp_taker-1]);
  99.                 else
  100.                     if (shoot_decide(&teams[setp_taker-1]))
  101.                         make_shoot(&teams[setp_taker-1]);
  102.                     else
  103.                         support_me=TRUE;        // No action (help).
  104.             break;
  105.  
  106.         case(SETP_PENALTY):
  107.             must_shoot=TRUE;
  108.             if (shoot_decide(&teams[setp_taker-1]))
  109.             {
  110.                 penalty_shot=TRUE;
  111.                 make_shoot(&teams[setp_taker-1]);
  112.             }
  113.             else
  114.                 support_me=TRUE;        // No action (help).
  115.             break;
  116.     }
  117. }
  118.  
  119. /******************************************************************************
  120. *****************************************************************************/
  121.  
  122. char all_standing()
  123. {
  124.     int i=0;
  125.     if (--setp_wait_cnt)
  126.     {
  127.         for (i=0; i<players; i++)
  128.         {
  129.             if (teams[i].guy_on>0 && teams[i].tm_act!=STAND_ACT && teams[i].tm_act!=PICKUP_ACT
  130.                  && teams[i].dir_mode!=6 && (teams[i].tm_act!=RUN_ACT || teams[i].tm_off!=-2))
  131.                 i=100;
  132.         }
  133.     }
  134.     else
  135.         setp_wait_cnt=1;
  136.  
  137.     return((i<=players) ? TRUE:FALSE);
  138. }
  139.  
  140. /******************************************************************************
  141. *****************************************************************************/
  142.  
  143. void clear_wall()
  144. {
  145.     for (int j=0; j<men_in_wall; j++)
  146.     {
  147.         teams[wguys[j].guy-1].tm_wall=0;
  148.     }
  149.     men_in_wall=0;
  150. }
  151.  
  152. /******************************************************************************
  153. *****************************************************************************/
  154.  
  155. void ready_set_kick()
  156. {
  157.     if (set_piece_on)
  158.     {
  159.         if (men_in_wall && (match_mode==DF_KICK_A || match_mode==DF_KICK_B))
  160.             clear_wall();
  161.  
  162.         arrow_on=FALSE;
  163.         match_mode=0;
  164.         offside_now=FALSE;
  165.         dead_ball_cnt=0;
  166.         game_action=0;
  167.         teams[setp_taker-1].tm_leave=-TRUE;    // Not allowed to touch ball after kick!
  168.         user_taker=0;
  169. // Referee normal mode...
  170.         refs[0].act=0;
  171.         set_piece_on=FALSE;
  172.         already_there=FALSE;
  173.         reselect();
  174.     }
  175. }
  176.  
  177. /******************************************************************************
  178. *****************************************************************************/
  179.  
  180. void go_set_kick(char type)
  181. {
  182.     short p;
  183.     if (type)
  184.     {
  185.         ready_set_kick();
  186.  
  187.         switch(type)
  188.         {
  189.             case(PASS_FEET):
  190.                 must_pass=TRUE;
  191.                 p=pass_decide(&teams[setp_taker-1],FALSE);
  192.                 if (p)
  193.                     make_pass(&teams[setp_taker-1],p,FALSE);
  194.                 break;
  195.  
  196.             case(PASS_HEAD):
  197.                 must_pass=TRUE;
  198.                 chip_pass=TRUE;
  199.                 p=(pass_decide(&teams[setp_taker-1],FALSE));
  200.                 if (p)
  201.                     make_pass(&teams[setp_taker-1],p,FALSE);
  202.                 break;
  203.  
  204.             case(PUNT):
  205.                 must_punt=TRUE;
  206.                 if (punt_decide(&teams[setp_taker-1]))
  207.                     make_punt(&teams[setp_taker-1]);
  208.                 break;
  209.  
  210.             default:
  211.                 must_pass=TRUE;
  212.                 break;
  213.         }
  214.     }
  215. }
  216.  
  217. /******************************************************************************
  218. *****************************************************************************/
  219.  
  220. void ready_ckick()
  221. {
  222.     arrow_on=FALSE;
  223.     match_mode=0;
  224.     dead_ball_cnt=0;
  225.     collect_ball(&teams[corner_taker-1]);
  226.     game_action=0;
  227.     teams[corner_taker-1].tm_leave=-TRUE;    // Not allowed to touch ball!
  228.     user_taker=0;
  229. }
  230.  
  231. /******************************************************************************
  232. *****************************************************************************/
  233.  
  234. void go_ckick(char type)
  235. {
  236.     if (type)
  237.     {
  238.         ready_ckick();
  239.         switch(type)
  240.         {
  241.             case(PASS_FEET):
  242.                 must_pass=TRUE;
  243.                 break;
  244.  
  245.             case(PASS_HEAD):
  246.                 must_pass=TRUE;
  247.                 break;
  248.  
  249.             case(PUNT):
  250.                 must_punt=TRUE;
  251.                 break;
  252.  
  253.             default:
  254.                 must_pass=TRUE;
  255.                 break;
  256.         }
  257.     }
  258. }
  259.  
  260. /******************************************************************************
  261. *****************************************************************************/
  262.  
  263. void await_set_kick()
  264. {
  265.     if (!hold_up_play)
  266.     {
  267.         if ((!player_on_off && (all_standing() && already_there) || (support_me)))
  268.         {
  269.             if (!allow_replay)
  270.                 init_replay();
  271.  
  272.             if (ball_poss!=setp_taker)
  273.                 collect_ball(&teams[setp_taker-1]);
  274.  
  275.             if (refs[0].act==4)
  276.             {
  277. // Referee wait for kick mode...
  278.                 refs[0].act=2;
  279.                 ktaker=setp_taker;
  280.                 ref_wait=(160-ref_strictness)*REAL_SPEED/8;
  281.                 play_fx(PS_SHORTWHISTLE,refs[0].x,refs[0].y);
  282.                 clock_running=TRUE;
  283.                 kickoff=FALSE;
  284.             }
  285.  
  286.             if (user_taker)
  287.             {
  288.                 if (reselection)
  289.                 {
  290.                     setp_kick_x=teams[setp_taker-1].tm_xdis;
  291.                     setp_kick_y=teams[setp_taker-1].tm_ydis;
  292.                     setp_power=0;
  293.                     setp_hgt=0;
  294.                     setp_byd=cntspot_y;
  295.                     reselection=FALSE;
  296.                     teams[setp_taker-1].dir_mode=1;
  297.                     teams[setp_taker-1].control=user_taker;
  298.                     users[user_taker-1].plr=setp_taker;
  299.                     
  300. #ifdef EURO96
  301.                     if (match_mode==PEN_KICK_A && user_taker2)
  302.                     {
  303.                         teams[KP_B-1].control=user_taker2;
  304.                         users[user_taker2-1].plr=KP_B;
  305.                     }
  306.                     if (match_mode==PEN_KICK_B && user_taker2)
  307.                     {
  308.                         teams[KP_A-1].control=user_taker2;
  309.                         users[user_taker2-1].plr=KP_A;
  310.                     }
  311. #endif
  312.  
  313.                     reselect_all_users();
  314.                     arrow_on=TRUE;
  315.                     arrow_guy=setp_taker;
  316.                     if (match_mode>=GOAL_KICK_TL && match_mode<=GOAL_KICK_BR)
  317.                         support_me=FALSE;
  318.                     else
  319.                         support_me=TRUE;
  320.                 }
  321.             }
  322.             else
  323.             {
  324.                 if (refs[0].act==2)
  325.                 {
  326. #ifdef EURO96
  327.                     if (match_mode!=PEN_KICK_A && match_mode!=PEN_KICK_B)
  328. #endif
  329.                     {
  330.                         decide_set_kick();
  331.                         if (!support_me)
  332. // Doesnt need support....
  333.                             ready_set_kick();
  334.                     }
  335.                 }
  336.             }
  337.         }
  338.     }
  339.     else
  340.         hold_up_play--;
  341. }
  342.  
  343. /*****************************************************************************
  344. *****************************************************************************/
  345.  
  346. void swap_users()
  347. {
  348.  
  349. // Team A users now play Team B...
  350.  
  351.     short p;
  352.     for (int u=0; u<num_of_users; u++)
  353.     {
  354.         if (users[u].type>0)
  355.         {
  356. // Fixed-player...
  357.             if (users[u].type>11)
  358.                 users[u].type-=11;
  359.             else
  360.                 users[u].type+=11;
  361.         }
  362.         else
  363.         {
  364. // Auto-player...
  365.             if (users[u].type==-1)
  366.                 users[u].type=-2;
  367.             else
  368.                 users[u].type=-1;
  369.         }
  370.  
  371.         p=users[u].plr;
  372.         if (p>11)
  373.             users[u].plr=p-11;
  374.         else
  375.             if (p<12 && p>0)
  376.                 users[u].plr=p+11;
  377.     }
  378.  
  379.     p=auto_users_a;
  380.     auto_users_a=auto_users_b;
  381.     auto_users_b=p;
  382.  
  383.     short t[10];
  384.     memcpy(&t,&auto_users_list_a,sizeof(t));
  385.     memcpy(&auto_users_list_a,&auto_users_list_b,sizeof(t));
  386.     memcpy(&auto_users_list_b,&t,sizeof(t));
  387. }
  388.  
  389. /*****************************************************************************
  390. *****************************************************************************/
  391.  
  392. void swap_teams()
  393. {
  394.     match_half+=1;
  395.  
  396.     match_player a;
  397.  
  398.     swap_users();
  399.  
  400.     for (short p=0; p<11; p++)
  401.     {
  402.         memcpy(&a,&teams[p],sizeof(a));
  403.         memcpy(&teams[p],&teams[p+11],sizeof(a));
  404.         memcpy(&teams[p+11],&a,sizeof(a));
  405.  
  406.         teams[p].tm_player=p+1;
  407.         teams[p+11].tm_player=p+12;
  408.     }
  409.  
  410.     char t=team_a;
  411.     team_a=team_b;
  412.     team_b=t;
  413.  
  414.     p=players_off_a;
  415.     players_off_a=players_off_b;
  416.     players_off_b=p;
  417.  
  418.     old_tac_a=-1;
  419.     old_tac_b=-1;
  420.     load_new_tactics();
  421. }
  422.  
  423. /*****************************************************************************
  424. *****************************************************************************/
  425.  
  426. char in_tunnel()
  427. {
  428.     for(short p=0; p<players; p++)
  429.     {
  430.         if (teams[p].draw_me)
  431.             return(FALSE);
  432.     }
  433.     return(TRUE);
  434. }
  435.     
  436. /*****************************************************************************
  437. *****************************************************************************/
  438.  
  439. void await_swap()
  440. {
  441.     if (in_tunnel() || !(timeout--))
  442.     {
  443.         if (match_half>=11)
  444.             end_game=TRUE;
  445.         else
  446.             swap_teams();
  447.  
  448.         camera=old_cam;
  449.  
  450.         if (last_centre)
  451.         {
  452. // Team A had last kick off...(not including goal respots)
  453.             last_centre=FALSE;
  454.             match_mode=CENTRE_B;
  455.             init_match_mode();
  456.         }
  457.         else
  458.         {
  459. // Team B had last kick off...(not including goal respots)
  460.             last_centre=TRUE;
  461.             match_mode=CENTRE_A;
  462.             init_match_mode();
  463.         }
  464.     }
  465. }
  466.  
  467. /*****************************************************************************
  468. *****************************************************************************/
  469.  
  470. void remember_cam()
  471. {
  472.     if (camera!=15)
  473.     {
  474.         old_cam=camera;
  475.     }
  476. // old_cam is already remembered if camera=15!
  477. }
  478.  
  479. /*****************************************************************************
  480. *****************************************************************************/
  481.  
  482. void init_swap_ends()
  483. {
  484.     allow_replay=FALSE;
  485.     remember_cam();
  486.     timeout=20*15;
  487.     clock_running=FALSE;
  488.     camera=16;
  489.     reset_ball();
  490.     dead_ball_cnt=40;
  491.     for (int i=0; i<players; i++)
  492.     {
  493.         init_stand_act(&teams[i]);
  494.     }
  495. }
  496.  
  497. /******************************************************************************
  498. *****************************************************************************/
  499.  
  500. void await_throw()
  501. {
  502.     if (already_there && !player_on_off)
  503.     {
  504.         float x=teams[throw_in_taker-1].tm_x;
  505.         float y=teams[throw_in_taker-1].tm_y;
  506.         if (calc_dist(incident_x-x,incident_y-y)<prat*3)
  507.         {
  508.             if (user_taker)
  509.             {
  510.                 if (reselection)
  511.                 {
  512.                     reselection=FALSE;
  513.                     teams[throw_in_taker-1].dir_mode=1;
  514.                     teams[throw_in_taker-1].control=user_taker;
  515.                     users[user_taker-1].plr=throw_in_taker;
  516.                     reselect_all_users();
  517.                     arrow_on=TRUE;
  518.                     arrow_guy=throw_in_taker;
  519.                 }
  520.             }
  521.  
  522.             if (ball_in_hands)
  523.             {
  524.                 match_mode=0;
  525.                 ball_in_hands=TRUE;
  526.                 init_throw_act(&teams[throw_in_taker-1]);
  527.                 collect_ball(&teams[throw_in_taker-1]);
  528.                 teams[throw_in_taker-1].tm_leave=-TRUE;    // Not allowed to touch ball!
  529.             }
  530.             else
  531.             {
  532.                 if (teams[throw_in_taker-1].tm_act!=PICKUP_ACT)
  533.                     init_pickup_act(&teams[throw_in_taker-1]);
  534.             }
  535.         }
  536.     }
  537. }
  538.  
  539. /******************************************************************************
  540. *****************************************************************************/
  541.  
  542. void ball_situation()
  543. {
  544.     if (match_mode)
  545.     {
  546.         if (match_mode==SWAP_ENDS)
  547. // Half time or extra time.
  548.             await_swap();
  549.         else
  550.             if (set_piece_on!=SETP_THROW)
  551.                 await_set_kick();
  552.             else
  553.                 await_throw();
  554.     }
  555. }
  556.  
  557. /******************************************************************************
  558. ******************************************************************************/
  559.  
  560. void stop()
  561. {
  562.     alarm=FALSE;
  563.     mf_fixed=TRUE;
  564.     stop_min+=1000;
  565.     watch=TRUE;
  566. }
  567.  
  568. /******************************************************************************
  569. ******************************************************************************/
  570.  
  571. void add_player_time()
  572. {
  573.     for (int p=0; p<22; p++)
  574.     {
  575.         teams[p].tm_time++;
  576.     }
  577. }
  578.  
  579. /******************************************************************************
  580. ******************************************************************************/
  581.  
  582. void match_clock()
  583. {
  584.     if (demo_match)
  585.         rolling_clock--;
  586.  
  587.     if (!match_mode && !penalty_game && !stop_clock && !just_scored)
  588.     {
  589.         match_time.sec+=90.0/(time_factor*REAL_SPEED);
  590.         if (match_time.sec>=60)
  591.         {
  592.             match_time.sec-=60;
  593.             match_time.min+=1;
  594.             add_player_time();
  595.         }
  596.  
  597.         if ((alarm) && (match_time.min>=stop_min) && (match_time.sec>=stop_sec))
  598.             stop();
  599.     }
  600. }
  601.  
  602. /******************************************************************************
  603. *****************************************************************************/
  604.  
  605. void kill_ball()
  606. {
  607.     reset_all_ideas();
  608.     holder_lose_ball();
  609.     stop_ball_spin();
  610.     ballxdis=0;
  611.     ballydis=0;
  612.     ballzdis=0;
  613.     ballx=incident_x;
  614.     bally=incident_y;
  615.     ballz=ball_diam/2;
  616.     dead_ball_cnt=50;
  617. }
  618.  
  619. /******************************************************************************
  620. *****************************************************************************/
  621.  
  622. void pen_to_team_a()
  623. {
  624.     away_pens_left--;
  625. // Team A penalty...
  626.  
  627.     match_mode=PEN_KICK_A;
  628.     do{
  629.         if (!(--pen_taker_a))
  630.             pen_taker_a=10;
  631.  
  632.     }while(!teams[pen_taker_a].guy_on);
  633.  
  634. // Guy hasn't been sent off!
  635.  
  636.     user_taker=user_taker_a(pen_taker_a+1);
  637.  
  638. #ifdef EURO96
  639.     user_taker2=user_keeper_b();
  640. #endif
  641.  
  642.     penalty_taker=pen_taker_a+1;
  643. }
  644.  
  645. /******************************************************************************
  646. *****************************************************************************/
  647.  
  648. void pen_to_team_b()
  649. {
  650.     home_pens_left--;
  651. // Team B penalty...
  652.  
  653.     match_mode=PEN_KICK_B;
  654.     do{
  655.         if ((--pen_taker_b)==11)
  656.             pen_taker_b=21;
  657.  
  658.     }while(!teams[pen_taker_b].guy_on);
  659.  
  660. // Guy hasn't been sent off!
  661.  
  662.     user_taker=user_taker_b(pen_taker_b+1);
  663.  
  664. #ifdef EURO96
  665.     user_taker2=user_keeper_a();
  666. #endif
  667.  
  668.     penalty_taker=pen_taker_b+1;
  669. }
  670.  
  671. /******************************************************************************
  672. *****************************************************************************/
  673.  
  674. void do_penalties()
  675. {
  676.     if (!match_mode)
  677.     {
  678. // Normal play...
  679.         if (!penalty_counter)
  680.         {
  681. // Next penalty...
  682.             if (penalties>=10 && !(penalties&1))
  683.             {
  684. // If at least 5 penalties each and both taken same no...
  685.                 if (team_a_goals!=team_b_goals)
  686.                 {
  687.                     penalty_game=FALSE;
  688.                 }
  689.             }
  690.             else
  691.             {
  692.                 if (penalties<10)
  693.                 {
  694.                     if (team_a_goals>team_b_goals)
  695.                     {
  696. // Home team winning...
  697.                         if (away_pens_left<(team_a_goals-team_b_goals))
  698.                             penalty_game=FALSE;
  699.                     }
  700.                     else
  701.                     {
  702. // Away team winning...
  703.                         if (home_pens_left<(team_b_goals-team_a_goals))
  704.                             penalty_game=FALSE;
  705.                     }
  706.                 }
  707.             }
  708.     
  709.             if (penalty_game)
  710.             {
  711.                 penalties++;
  712.                 penalty_counter=5*REAL_SPEED;
  713.                 kill_ball();
  714.                 game_action=2;        // gather outside box!
  715.                 if (!penalty_team)
  716.                 {
  717.                     penalty_team=TRUE;        // Setup next for team!
  718.                     if (match_half&1)
  719.                         pen_to_team_b();
  720.                     else
  721.                         pen_to_team_a();
  722.                 }
  723.                 else
  724.                 {
  725.                     penalty_team=FALSE;        // Setup next for team!
  726.                     if (match_half&1)
  727.                         pen_to_team_a();
  728.                     else
  729.                         pen_to_team_b();
  730.                 }
  731.                 init_match_mode();
  732.             }
  733.         }
  734.         else
  735.         {
  736.             penalty_counter--;
  737.         }
  738.     }
  739. }
  740.  
  741. /******************************************************************************
  742. *****************************************************************************/
  743.  
  744. void match_rules()
  745. {
  746.     if (penalty_game)
  747.     {
  748.         if (match_mode!=PEN_KICK_A && match_mode!=PEN_KICK_B && match_mode!=SWAP_ENDS)
  749.             match_mode=0;
  750.  
  751.         do_penalties();
  752.     }
  753.  
  754.     match_clock();
  755.     if (dead_ball_cnt)
  756.         ball_situation();
  757. }
  758.  
  759. /******************************************************************************
  760. *****************************************************************************/
  761.  
  762. char bounds_rules()
  763. {
  764.  
  765.     float xoff=0;
  766.     float yoff=0;
  767.  
  768. /***********************/
  769.  
  770.     if (ballx<0)
  771.     {
  772. // Past Left Goal-line...
  773.         xoff=-ballx;
  774.  
  775.         if (last_touch<12)
  776.         {
  777. // Corner!
  778.             if (!team_b_on)
  779.             {
  780.                 if (bally>cntspot_y)
  781.                     return(GOAL_KICK_BL);
  782.                 else
  783.                     return(GOAL_KICK_TL);
  784.             }
  785.             else
  786.             {
  787.                 if (bally>cntspot_y)
  788.                     return(CORNER_BL);
  789.                 else
  790.                     return(CORNER_TL);
  791.             }
  792.         }
  793.         else
  794.         {
  795. // Goal Kick!
  796.             if (!team_a_on)
  797.             {
  798.                 if (bally>cntspot_y)
  799.                     return(CORNER_BL);
  800.                 else
  801.                     return(CORNER_TL);
  802.             }
  803.             else
  804.             {
  805.                 if (bally>cntspot_y)
  806.                     return(GOAL_KICK_BL);
  807.                 else
  808.                     return(GOAL_KICK_TL);
  809.             }
  810.         }
  811.     }
  812.  
  813. /***********************/
  814.  
  815.     if (ballx>=pitch_len)
  816.     {
  817. // Past Right Goal-line...
  818.         xoff=ballx-(pitch_len-1);
  819.  
  820.         if (last_touch>11)
  821.         {
  822. // Corner!
  823.             if (!team_a_on)
  824.             {
  825.                 if (bally>cntspot_y)
  826.                     return(GOAL_KICK_BR);
  827.                 else
  828.                     return(GOAL_KICK_TR);
  829.             }
  830.             else
  831.             {
  832.                 if (bally>cntspot_y)
  833.                     return(CORNER_BR);
  834.                 else
  835.                     return(CORNER_TR);
  836.             }
  837.         }
  838.         else
  839.         {
  840. // Goal Kick!
  841.             if (!team_b_on)
  842.             {
  843.                 if (bally>cntspot_y)
  844.                     return(CORNER_BR);
  845.                 else
  846.                     return(CORNER_TR);
  847.             }
  848.             else
  849.             {
  850.                 if (bally>cntspot_y)
  851.                     return(GOAL_KICK_BR);
  852.                 else
  853.                     return(GOAL_KICK_TR);
  854.             }
  855.         }
  856.     }
  857.  
  858. /***********************/
  859.  
  860.     if (bally<0)
  861.         yoff=-bally;
  862.  
  863.     if (bally>=pitch_wid)
  864.         yoff=bally-(pitch_wid-1);
  865.  
  866.     if (yoff>xoff)
  867.     {
  868. // Over top side-line...
  869.  
  870.         incident_x=ballx;
  871.         incident_y=((bally<0) ? 0:pitch_wid-1);
  872.  
  873.         if (last_touch<12)
  874.         
  875. // Throw-in to team B!
  876.             if (!team_b_on)
  877.                 return(THROW_IN_A);
  878.             else
  879.                 return(THROW_IN_B);
  880.         else
  881.             if (!team_a_on)
  882.                 return(THROW_IN_B);
  883.             else
  884.                 return(THROW_IN_A);
  885.         
  886.     }
  887.     return(0);
  888. }
  889.  
  890. /******************************************************************************
  891. *****************************************************************************/
  892. // INITIALISE MATCH SITUATIONS...
  893. /******************************************************************************
  894. *****************************************************************************/
  895.  
  896. /******************************************************************************
  897. *****************************************************************************/
  898.  
  899. void throw_taker(int p)
  900. {
  901. // Decision is made on the closest tactical position at current ball_zone...
  902.  
  903.     int min_d=1000;
  904.     int d;
  905.  
  906.     for (int pn=p; pn<p+10; pn++)
  907.     {
  908.         if (teams[pn-1].guy_on>0)
  909.         {
  910.             if (pn<12)
  911.                 d=calc_dist(ballx-match_tactics1[ball_zone1][pn-2][0],
  912.                                bally-match_tactics1[ball_zone1][pn-2][1]);
  913.             else
  914.                 d=calc_dist((pitch_len-ballx)-match_tactics2[ball_zone2][pn-13][0],
  915.                                (pitch_wid-bally)-match_tactics2[ball_zone2][pn-13][1]);
  916.         
  917.             if (d<min_d)
  918.             {
  919.                 min_d=d;
  920.                 throw_in_taker=pn;
  921.             }
  922.         }
  923.     }
  924. }
  925.  
  926. /******************************************************************************
  927. *****************************************************************************/
  928.  
  929. int get_taker(int p)
  930. {
  931. // Decision is made on the closest tactical position at current ball_zone...
  932.  
  933.     int min_d=1000;
  934.     int d,taker;
  935.  
  936.     for (int pn=p; pn<(p<12 ? 12:23); pn++)
  937.     {
  938.         if (teams[pn-1].guy_on>0)
  939.         {
  940.             if (pn==KP_A)
  941.                 d=calc_dist(ballx-0,bally-cntspot_y);
  942.             else
  943.                 if (pn==KP_B)
  944.                     d=calc_dist(pitch_len,bally-cntspot_y);
  945.                 else
  946.                     if (pn<12)
  947.                         d=calc_dist(ballx-match_tactics1[ball_zone1][pn-2][0],
  948.                                        bally-match_tactics1[ball_zone1][pn-2][1]);
  949.                     else
  950.                         d=calc_dist((pitch_len-ballx)-match_tactics2[ball_zone2][pn-13][0],
  951.                                        (pitch_wid-bally)-match_tactics2[ball_zone2][pn-13][1]);
  952.  
  953.             if (d<min_d)
  954.             {
  955.                 min_d=d;
  956.                 taker=pn;
  957.             }
  958.         }
  959.     }
  960.     return(taker);
  961. }
  962.  
  963. /******************************************************************************
  964. *****************************************************************************/
  965.  
  966. void centre_takers()
  967. {
  968.     int p;
  969.     centre_guy_1=0;
  970.     centre_guy_2=0;
  971.  
  972.     if (match_mode==CENTRE_A)
  973.     {
  974.         p=2;
  975.         flag=TRUE;
  976.     }
  977.     else
  978.     {
  979.         p=13;
  980.         flag=FALSE;
  981.     }
  982.  
  983.     int d;
  984.     int min_d=1000;
  985.  
  986. // Decide on which two players shall take centre.
  987.  
  988. // Decision is made on the two closest tactical positions...
  989.  
  990.     for (int pn=p; pn<p+10; pn++)
  991.     {
  992.         if (teams[pn-1].guy_on>0)
  993.         {
  994.             if (flag)
  995.                 d=calc_dist(cntspot_x-match_tactics1[68][pn-2][0],
  996.                                cntspot_y-match_tactics1[68][pn-2][1]);
  997.             else
  998.                 d=calc_dist(cntspot_x-match_tactics2[68][pn-13][0],
  999.                                cntspot_y-match_tactics2[68][pn-13][1]);
  1000.  
  1001.             if (d<min_d)
  1002.             {
  1003.                 min_d=d;
  1004.                 centre_guy_1=pn;
  1005.             }
  1006.         }
  1007.     }
  1008.  
  1009.     min_d=1000;
  1010.     for (pn=p; pn<p+10; pn++)
  1011.     {
  1012.         if (teams[pn-1].guy_on>0)
  1013.         {
  1014.             if (flag)
  1015.                 d=calc_dist(cntspot_x-match_tactics1[68][pn-2][0],
  1016.                                cntspot_y-match_tactics1[68][pn-2][1]);
  1017.             else
  1018.                 d=calc_dist(cntspot_x-match_tactics2[68][pn-13][0],
  1019.                                cntspot_y-match_tactics2[68][pn-13][1]);
  1020.  
  1021.             if ((d<min_d) && (centre_guy_1!=pn))
  1022.             {
  1023.                 min_d=d;
  1024.                 centre_guy_2=pn;
  1025.             }
  1026.         }
  1027.     }
  1028. }
  1029.  
  1030. /******************************************************************************
  1031. *****************************************************************************/
  1032.  
  1033. void init_centre()
  1034. {
  1035.     if (kickoff && next_mins)
  1036.     {
  1037.         match_time.min=next_mins;
  1038.         match_time.sec=0;
  1039.         match_mode=CENTRE_A;
  1040.         last_goal=0;
  1041.     }
  1042.                                         
  1043.     reset_ball();
  1044.     dead_ball_cnt=40;
  1045.     ballx=cntspot_x;
  1046.     bally=cntspot_y;
  1047.     ballz=ball_diam/2;
  1048.  
  1049.     if (match_mode==CENTRE_A)
  1050.     {
  1051. // Team A centre.
  1052.         ball_zone1=68;
  1053.         ball_zone2=69;
  1054.         refs[0].goto_x=cntspot_x+5*prat;
  1055.         centre_takers();
  1056.         do_kickoff_menu(team_a);
  1057.     }
  1058.     else
  1059.     {
  1060. // Team B centre.
  1061.         ball_zone2=68;
  1062.         ball_zone1=69;
  1063.         refs[0].goto_x=cntspot_x-5*prat;
  1064.         centre_takers();
  1065.         do_kickoff_menu(team_b);
  1066.     }
  1067.  
  1068.     game_action=1;        // 10 Yards away!
  1069.  
  1070. // Referee go to spot behind incident...
  1071.     refs[0].act=1;
  1072.     refs[0].target=0;    // Ball!
  1073.     refs[0].goto_y=cntspot_y;
  1074.  
  1075.     main_man=centre_guy_1;
  1076.  
  1077.     user_taker=0;
  1078. /*
  1079.     if (centre_guy_1>11)
  1080.         user_taker=user_taker_b(centre_guy_1);
  1081.     else
  1082.         user_taker=user_taker_a(centre_guy_1);
  1083. */
  1084. }
  1085.  
  1086. /******************************************************************************
  1087. *****************************************************************************/
  1088.  
  1089. void init_corner()
  1090. {
  1091.     PlayCommentaryMessage(SP_CORNER);
  1092.  
  1093.     comsetp=40;
  1094.     user_taker=0;
  1095.     dead_ball_cnt=20;
  1096.     switch(match_mode)
  1097.     {
  1098.         case(CORNER_TL):
  1099.             ballx=prat-1;
  1100.             bally=prat-1;
  1101.             ballz=ball_diam/2;
  1102.             ball_zone1=64;
  1103.             ball_zone2=67;
  1104.             last_touch=12;            // team b has possession.
  1105.  
  1106.             if ((corn_kicker_b) && (teams[corn_kicker_b-1].guy_on>0))
  1107.                 corner_taker=corn_kicker_b;
  1108.             else
  1109.                 corner_taker=get_taker(13);
  1110.  
  1111.             do_corner_menu(team_b);
  1112.  
  1113.             break;
  1114.  
  1115.         case(CORNER_BL):
  1116.             ballx=prat-1;
  1117.             bally=pitch_wid-prat+1;
  1118.             ballz=ball_diam/2;
  1119.             ball_zone1=66;
  1120.             ball_zone2=65;
  1121.             last_touch=12;            // team b has possession.
  1122.  
  1123.             if ((corn_kicker_b) && (teams[corn_kicker_b-1].guy_on>0))
  1124.                 corner_taker=corn_kicker_b;
  1125.             else
  1126.                 corner_taker=get_taker(13);
  1127.  
  1128.             do_corner_menu(team_b);
  1129.  
  1130.             break;
  1131.  
  1132.         case(CORNER_TR):
  1133.             ballx=pitch_len-prat+1;
  1134.             bally=prat-1;
  1135.             ballz=ball_diam/2;
  1136.             ball_zone1=65;
  1137.             ball_zone2=66;
  1138.             last_touch=1;            // team a has possession.
  1139.  
  1140.             if ((corn_kicker_a) && (teams[corn_kicker_a-1].guy_on>0))
  1141.                 corner_taker=corn_kicker_a;
  1142.             else
  1143.                 corner_taker=get_taker(2);
  1144.  
  1145.             do_corner_menu(team_a);
  1146.  
  1147.             break;
  1148.  
  1149.         case(CORNER_BR):
  1150.             ballx=pitch_len-prat+1;
  1151.             bally=pitch_wid-prat+1;
  1152.             ballz=ball_diam/2;
  1153.             ball_zone1=67;
  1154.             ball_zone2=64;
  1155.             last_touch=1;            // team a has possession.
  1156.  
  1157.             if ((corn_kicker_a) && (teams[corn_kicker_a-1].guy_on>0))
  1158.                 corner_taker=corn_kicker_a;
  1159.             else
  1160.                 corner_taker=get_taker(2);
  1161.  
  1162.             do_corner_menu(team_a);
  1163.  
  1164.             break;
  1165.     }
  1166.  
  1167.     incident_x=ballx+((ballx<cntspot_x) ? -4:4);
  1168.     incident_y=bally+((bally<cntspot_y) ? -8:8);
  1169.     game_action=1;        // 10 Yards away!
  1170.  
  1171.     if (corner_taker>11)
  1172.         user_taker=user_taker_b(corner_taker);
  1173.     else
  1174.         user_taker=user_taker_a(corner_taker);
  1175.  
  1176.     main_man=corner_taker;
  1177.  
  1178. // Referee go to spot between centre spot and ball...
  1179.     refs[0].act=1;
  1180.     refs[0].target=0;    // Ball!
  1181.     refs[0].goto_x=cntspot_x+((ballx-cntspot_x)/2);
  1182.     refs[0].goto_y=cntspot_y+((bally-cntspot_y)/2);
  1183.     last_touch=main_man;
  1184.     pre_kp_touch=last_touch;
  1185.     ball_in_hands=FALSE;
  1186. }
  1187.  
  1188. /******************************************************************************
  1189. *****************************************************************************/
  1190.  
  1191. void init_gkick()
  1192. {
  1193.     if (fired_a_shot)
  1194.     {
  1195.         if ((ABS(bally_out-cntspot_y)>prat*7) || (ballz_out>prat*4))
  1196. // Miles away...
  1197.             PlayCommentaryMessage(PM_WIDE);
  1198.         else
  1199. // Near miss..
  1200.             PlayCommentaryMessage(PM_CLOSE);
  1201.     }
  1202.     else
  1203.         PlayCommentaryMessage(SP_GOALKICK);
  1204.  
  1205.     dead_ball_cnt=100;
  1206.     switch(match_mode)
  1207.     {
  1208.         case(GOAL_KICK_TL):
  1209.             ballx=(5.8*prat);
  1210.             bally=cntspot_y-(5.0*prat);
  1211.             ballz=ball_diam/2;
  1212.             ball_zone1=11;
  1213.             ball_zone2=20;
  1214.             last_touch=1;            // team a has possession.
  1215.  
  1216.             if ((goal_kicker_a) && (teams[goal_kicker_a-1].guy_on>0))
  1217.                 gkick_taker=goal_kicker_a;
  1218.             else
  1219.                 gkick_taker=get_taker(1);
  1220.  
  1221.             do_goalkick_menu(team_a);
  1222.             break;
  1223.  
  1224.         case(GOAL_KICK_BL):
  1225.             ballx=(5.8*prat);
  1226.             bally=cntspot_y+(5.0*prat);
  1227.             ballz=ball_diam/2;
  1228.             ball_zone1=19;
  1229.             ball_zone2=12;
  1230.             last_touch=1;            // team a has possession.
  1231.  
  1232.             if ((goal_kicker_a) && (teams[goal_kicker_a-1].guy_on>0))
  1233.                 gkick_taker=goal_kicker_a;
  1234.             else
  1235.                 gkick_taker=get_taker(1);
  1236.  
  1237.             do_goalkick_menu(team_a);
  1238.             break;
  1239.  
  1240.         case(GOAL_KICK_TR):
  1241.             ballx=pitch_len-(5.8*prat);
  1242.             bally=cntspot_y-(5.0*prat);
  1243.             ballz=ball_diam/2;
  1244.             ball_zone1=12;
  1245.             ball_zone2=19;
  1246.             last_touch=12;            // team b has possession.
  1247.  
  1248.             if ((goal_kicker_b) && (teams[goal_kicker_b-1].guy_on>0))
  1249.                 gkick_taker=goal_kicker_b;
  1250.             else
  1251.                 gkick_taker=get_taker(12);
  1252.  
  1253.             do_goalkick_menu(team_b);
  1254.             break;
  1255.  
  1256.         case(GOAL_KICK_BR):
  1257.             ballx=pitch_len-(5.8*prat);
  1258.             bally=cntspot_y+(5.0*prat);
  1259.             ballz=ball_diam/2;
  1260.             ball_zone1=20;
  1261.             ball_zone2=11;
  1262.             last_touch=12;            // team b has possession.
  1263.  
  1264.             if ((goal_kicker_b) && (teams[goal_kicker_b-1].guy_on>0))
  1265.                 gkick_taker=goal_kicker_b;
  1266.             else
  1267.                 gkick_taker=get_taker(12);
  1268.  
  1269.             do_goalkick_menu(team_b);
  1270.             break;
  1271.     }
  1272.     incident_x=ballx;
  1273.     incident_y=bally;
  1274.     game_action=1;        // 10 Yards away!
  1275.  
  1276.     main_man=gkick_taker;
  1277.  
  1278. // Referee go to spot between centre spot and ball...
  1279.     refs[0].act=1;
  1280.     refs[0].target=0;    // Ball!
  1281.     refs[0].goto_x=cntspot_x+((ballx-cntspot_x)/2);
  1282.     refs[0].goto_y=cntspot_y+((bally-cntspot_y)/2);
  1283.     last_touch=main_man;
  1284.     pre_kp_touch=last_touch;
  1285.  
  1286.     user_taker=0;
  1287.  
  1288.     if (gkick_taker>11)
  1289.         user_taker=user_taker_b(gkick_taker);
  1290.     else
  1291.         user_taker=user_taker_a(gkick_taker);
  1292.  
  1293.     float ang=(64.-seed)*(PI/(8*64));
  1294.  
  1295.     if (match_mode<GOAL_KICK_TR)
  1296.     {
  1297. // Goal_kick to team A...
  1298.         taker_x=ballx-(cos(ang)*4);
  1299.         taker_y=bally+(sin(ang)*4);
  1300.     }
  1301.     else
  1302.     {
  1303. // Goal_kick to team B...
  1304.         taker_x=ballx+(cos(ang)*4);
  1305.         taker_y=bally+(sin(ang)*4);
  1306.     }
  1307. }
  1308.  
  1309. /******************************************************************************
  1310. *****************************************************************************/
  1311.  
  1312. void init_throw()
  1313. {
  1314.     stop_clock=TRUE;
  1315.     user_taker=0;
  1316.     dead_ball_cnt=100;
  1317.     if (match_mode==THROW_IN_A)
  1318.     {
  1319.         do_throw_menu(team_a);
  1320.         last_touch=1;        // Team A have possession...
  1321.         throw_taker(2);
  1322.         if (ballx_out>(pitch_len-(prat*20)))
  1323.             PlayCommentaryMessage(SP_LONGTHROWIN);
  1324.         else
  1325.             PlayCommentaryMessage(SP_THROWIN);
  1326.  
  1327.     }
  1328.     if (match_mode==THROW_IN_B)
  1329.     {
  1330.         do_throw_menu(team_b);
  1331.         last_touch=12;        // Team B have possession...
  1332.         throw_taker(13);
  1333.         if (ballx_out<(prat*20))
  1334.             PlayCommentaryMessage(SP_LONGTHROWIN);
  1335.         else
  1336.             PlayCommentaryMessage(SP_THROWIN);
  1337.     }
  1338.  
  1339.     teams[throw_in_taker-1].int_move=I_THROW;
  1340.  
  1341.     ballx=incident_x;
  1342.     bally=incident_y;
  1343.  
  1344.     ballz=ball_diam/2;
  1345.     game_action=1;        // 10 Yards away!
  1346.  
  1347.     if (throw_in_taker>11)
  1348.         user_taker=user_taker_b(throw_in_taker);
  1349.     else
  1350.         user_taker=user_taker_a(throw_in_taker);
  1351.  
  1352. // Linesman go to spot behind incident...
  1353.     if (bally>cntspot_y)
  1354. // Bottom linesman....
  1355.     {
  1356.         refs[2].act=1;
  1357.         refs[2].goto_y=refs[2].y;
  1358.         if (refs[2].x>ballx+prat*4)
  1359.             refs[2].goto_x=ballx+prat*4;
  1360.         else
  1361.             if (refs[2].x<ballx-prat*4)
  1362.                 refs[2].goto_x=ballx-prat*4;
  1363.             else
  1364.                 refs[2].act=0;
  1365.     }
  1366.     else
  1367. // Top linesman....
  1368.     {
  1369.         refs[1].act=1;                
  1370.         refs[1].goto_y=refs[1].y;
  1371.         if (refs[1].x>ballx+prat*4)
  1372.             refs[1].goto_x=ballx+prat*4;
  1373.         else
  1374.             if (refs[1].x<ballx-prat*4)
  1375.                 refs[1].goto_x=ballx-prat*4;
  1376.             else
  1377.                 refs[1].act=0;
  1378.     }
  1379.     main_man=throw_in_taker;
  1380. }
  1381.  
  1382. /******************************************************************************
  1383. *****************************************************************************/
  1384.  
  1385. char penalty(int fouler)
  1386. {
  1387.     if (ballx<cntspot_x)
  1388.     {
  1389. // Team A box...
  1390.         if ((fouler<12) && (ballx<prat*18) && (bally<cntspot_y+(prat*22)) && (bally>cntspot_y-(prat*22)))
  1391.             return(TRUE);
  1392.     }
  1393.     else
  1394.     {
  1395. // Team B box...
  1396.         if ((fouler>11) && (ballx>pitch_len-(prat*18)) && (bally<cntspot_y+(prat*22)) && (bally>cntspot_y-(prat*22)))
  1397.             return(TRUE);
  1398.     }
  1399.     return(FALSE);
  1400. }
  1401.  
  1402. /******************************************************************************
  1403. *****************************************************************************/
  1404.  
  1405. void init_offside(match_player *player)
  1406. {
  1407.     float d,x;
  1408.  
  1409.     if (player->tm_player>11)
  1410. // Top linesman...
  1411.     {
  1412.         x=defense_a-player->tm_x;        // How much offside.
  1413.         d=(pitch_wid-calc_dist(player->tm_x-refs[1].x,player->tm_y-refs[1].y))/prat;
  1414.     }
  1415.     else
  1416. // Bot linesman...
  1417.     {
  1418.         x=player->tm_x-defense_b;        // How much offside.
  1419.         d=(pitch_wid-calc_dist(player->tm_x-refs[2].x,player->tm_y-refs[2].y))/prat;
  1420.     }
  1421.  
  1422.     d=ref_accuracy/2+(ref_accuracy*((d*d*0.000740740)-(0.07*d)+1));
  1423.     if (d<1)
  1424.         d=1;
  1425.  
  1426.     if (seed<d/2+x)
  1427.     {
  1428.  
  1429. // The linesman sees the Offside...
  1430.         player->tm_off=TRUE;
  1431.     }
  1432.     else
  1433.     {
  1434.         short rel=(128-ref_accuracy)/4;
  1435.         player->tm_off=-TRUE;
  1436.         if (ball_released<0)
  1437.         {
  1438.             ball_released+=rel;
  1439.             if (ball_released>0)
  1440.                 ball_released=0;
  1441.         }
  1442.         else
  1443.         {
  1444.             ball_released-=rel;
  1445.             if (ball_released<0)
  1446.                 ball_released=0;
  1447.         }
  1448.     }
  1449. }
  1450.  
  1451. /******************************************************************************
  1452. *****************************************************************************/
  1453.  
  1454. void big_yeller(int plr)
  1455. {
  1456.     card_is_out=3*REAL_SPEED;
  1457.     int t;
  1458.     booking=TRUE;
  1459.  
  1460.     if (plr<12)
  1461.         t=team_a;
  1462.     else
  1463.         t=team_b;
  1464.  
  1465.     PlayCommentaryMessage(FU_YELLOWCARD);
  1466.     do_booked_menu(t,teams[plr-1].shirt-1);
  1467.     inc_yellow(plr);
  1468. }
  1469.  
  1470. /******************************************************************************
  1471. *****************************************************************************/
  1472.  
  1473. void ger_em_off(int plr)
  1474. {
  1475. // Off
  1476.     inc_red(plr);
  1477.     card_is_out=6*REAL_SPEED;
  1478.     booking=TRUE;
  1479.     if (plr<12)
  1480.         players_off_a++;
  1481.     else
  1482.         players_off_b++;
  1483.  
  1484.     player_on_off=plr;
  1485.     sub_camera=camera;
  1486.     camera=17;
  1487.     reset_ideas(&teams[plr-1]);
  1488.     init_off_int(&teams[plr-1]);
  1489.     PlayCommentaryMessage(FU_REDCARD);
  1490.  
  1491.     int t,p;
  1492.  
  1493.     if (plr<12)
  1494.     {
  1495.         t=team_a;
  1496.         game_data[team_a==0 ? setup.team_a:setup.team_b].players[plr-1].flags|=2;
  1497.     }
  1498.     else
  1499.     {
  1500.         t=team_b;
  1501.         game_data[team_b==0 ? setup.team_a:setup.team_b].players[plr-12].flags|=2;
  1502.     }
  1503.  
  1504.     do_off_menu(t,teams[plr-1].shirt-1);
  1505.  
  1506. //    teams[plr-1].guy_on=-1;            // Waiting to be sent off!
  1507.  
  1508.     if (corn_kicker_a==plr)
  1509.         corn_kicker_a=0;
  1510.  
  1511.     if (corn_kicker_b==plr)
  1512.         corn_kicker_b=0;
  1513.  
  1514.     if (goal_kicker_a==plr)
  1515.         if (plr<12)
  1516.             goal_kicker_a=KP_A;
  1517.         else
  1518.             goal_kicker_a=KP_B;
  1519.  
  1520.     if (goal_kicker_b==plr)
  1521.         if (plr<12)
  1522.             goal_kicker_a=KP_A;
  1523.         else
  1524.             goal_kicker_a=KP_B;
  1525.  
  1526.     if    (fkick_taker_a==plr)
  1527.         fkick_taker_a=0;
  1528.  
  1529.     if    (fkick_taker_b==plr)
  1530.         fkick_taker_b=0;
  1531. }
  1532.  
  1533. /******************************************************************************
  1534. *****************************************************************************/
  1535.  
  1536. void send_off_plr(int plr,float nasty)
  1537. {
  1538.     if (plr!=KP_A && plr!=KP_B && EUROmatch_info.bookings)
  1539.     {
  1540.         if (teams[plr-1].tm_book)
  1541.         {
  1542. // He's had a yellow card...
  1543.             if (nasty>seed)
  1544.             {
  1545.                 if ((plr<12 && players_off_a<5) || (plr>11 && players_off_b<5))
  1546.                     ger_em_off(plr);
  1547.             }
  1548.         }
  1549.         else
  1550.         {
  1551.              if (nasty>seed*4)
  1552.             {
  1553.                 if ((plr<12 && players_off_a<5) || (plr>11 && players_off_b<5))
  1554.                     ger_em_off(plr);
  1555.             }
  1556.             else
  1557.                 if (nasty>seed)
  1558.                     big_yeller(plr);
  1559.         }
  1560.     }
  1561. }
  1562.  
  1563. /******************************************************************************
  1564. *****************************************************************************/
  1565.  
  1566. void punish_foul(int fouler,char direct)
  1567. {
  1568.     user_taker=0;
  1569.     in_range=FALSE;
  1570.     reset_all_ideas();
  1571.     holder_lose_ball();
  1572.     stop_ball_spin();
  1573.     ballxdis=0;
  1574.     ballydis=0;
  1575.     ballzdis=0;
  1576.     ballx=incident_x;
  1577.     bally=incident_y;
  1578.     ballz=ball_diam/2;
  1579.     dead_ball_cnt=50;
  1580.     last_touch=fouler;
  1581.  
  1582.     float nastiness;
  1583.  
  1584.     booking=0;
  1585.     nastiness=sqrt(teams[last_touch-1].tm_dist*4)*ref_strictness/6;            // distance to ball. (how late was the challenge?)
  1586.     if (!man_down)
  1587.         nastiness/=3;
  1588.  
  1589. // Shall we send him off?
  1590.     if (direct)
  1591.         send_off_plr(last_touch,nastiness);
  1592.  
  1593.     if (direct && (penalty(fouler)))
  1594.     {
  1595.         inc_pfoul(fouler);
  1596.  
  1597.         if (seed&2 && !player_on_off)
  1598.             PlayCommentaryMessage(FU_DIVE);
  1599.  
  1600.         init_speech(players+1,SAY_PENALTY);
  1601.         game_action=2;        // gather outside box!
  1602.         if (fouler>11)
  1603. // Team A P.K.
  1604.         {
  1605.             match_mode=PEN_KICK_A;
  1606.             if ((penalty_taker_a) && (teams[penalty_taker_a-1].guy_on>0))
  1607.                 penalty_taker=penalty_taker_a;
  1608.             else
  1609.                 penalty_taker=get_taker(2);
  1610.  
  1611.             if (!booking)
  1612.                 do_penalty_menu(team_a);
  1613.  
  1614.             user_taker=user_taker_a(penalty_taker);
  1615. #ifdef EURO96
  1616.             user_taker2=user_keeper_b();
  1617. #endif
  1618.         }
  1619.         else
  1620. // Team B P.K.
  1621.         {
  1622.             match_mode=PEN_KICK_B;
  1623.             if ((penalty_taker_b) && (teams[penalty_taker_b-1].guy_on>0))
  1624.                 penalty_taker=penalty_taker_b;
  1625.             else
  1626.                 penalty_taker=get_taker(13);
  1627.  
  1628.             if (!booking)
  1629.                 do_penalty_menu(team_b);
  1630.  
  1631.             user_taker=user_taker_b(penalty_taker);
  1632. #ifdef EURO96
  1633.             user_taker2=user_keeper_a();
  1634. #endif
  1635.         }
  1636.     }
  1637.     else
  1638.     {
  1639.         game_action=1;        // 10 Yards away!
  1640.         if (fouler>11)
  1641. // Team A F.K.
  1642.         {
  1643.             if (!direct)
  1644.             {
  1645. // Not on the ball..(INDIRECT)
  1646.                 inc_ifoul(fouler);
  1647.                 init_speech(players+1,SAY_OFFSIDE);
  1648.                 match_mode=IF_KICK_A;
  1649.                 fkick_taker=get_taker(2);
  1650.                 if (!booking)
  1651.                     if (offside_now)
  1652.                         do_offside_menu(team_a);
  1653.                     else
  1654.                         do_indirect_menu(team_a);
  1655.             }
  1656.             else
  1657. // On the ball..(DIRECT)
  1658.             {
  1659.                 if (!player_on_off)
  1660.                 {
  1661.                     if (seed&64)
  1662.                         PlayCommentaryMessage(FU_BADFOUL);
  1663.                     else
  1664.                         PlayCommentaryMessage(FU_FREEKICK);
  1665.                 }
  1666.  
  1667.                 inc_dfoul(fouler);
  1668.                 init_speech(players+1,SAY_FOUL);
  1669.                 match_mode=DF_KICK_A;
  1670.                 if ((fkick_taker_a) && (teams[fkick_taker_a-1].guy_on>0))
  1671.                     fkick_taker=fkick_taker_a;
  1672.                 else
  1673.                     fkick_taker=get_taker(2);
  1674.             }
  1675.                 user_taker=user_taker_a(fkick_taker);
  1676.         }
  1677.         else
  1678. // Team B F.K.
  1679.         {
  1680.             if (!direct)
  1681.             {
  1682. // Not on the ball..(INDIRECT)
  1683.                 inc_ifoul(fouler);
  1684.                 init_speech(players+1,SAY_OFFSIDE);
  1685.                 match_mode=IF_KICK_B;
  1686.                 fkick_taker=get_taker(13);
  1687.                 if (!booking)
  1688.                     if (offside_now)
  1689.                         do_offside_menu(team_b);
  1690.                     else
  1691.                         do_indirect_menu(team_a);
  1692.             }
  1693.             else
  1694. // On the ball..(DIRECT)
  1695.             {
  1696.                 if (!player_on_off)
  1697.                 {
  1698.                     if (seed&64)
  1699.                         PlayCommentaryMessage(FU_BADFOUL);
  1700.                     else
  1701.                         PlayCommentaryMessage(FU_FREEKICK);
  1702.                 }
  1703.  
  1704.                 inc_dfoul(fouler);
  1705.                 init_speech(players+1,SAY_FOUL);
  1706.                 match_mode=DF_KICK_B;
  1707.                 if ((fkick_taker_b) && (teams[fkick_taker_b-1].guy_on>0))
  1708.                     fkick_taker=fkick_taker_b;
  1709.                 else
  1710.                     fkick_taker=get_taker(13);
  1711.             }
  1712.                 user_taker=user_taker_b(fkick_taker);
  1713.         }
  1714.     }
  1715.     init_match_mode();
  1716. }
  1717.  
  1718. /******************************************************************************
  1719. *****************************************************************************/
  1720.  
  1721. void retake_foul()
  1722. {
  1723.     punish_foul(bad_guy,direct_fk);
  1724.     play_advantage=FALSE;
  1725. }
  1726.  
  1727. /******************************************************************************
  1728. *****************************************************************************/
  1729.  
  1730. void init_foul(int fouler,char direct,char see)
  1731. {    
  1732.     play_advantage=FALSE;
  1733.     af_randomize();
  1734.     float x,y,d;
  1735.     d=calc_dist(ballx-refs[0].x,bally-refs[0].y)/prat;
  1736.     d=(ref_accuracy/d)*2*man_down;
  1737.  
  1738.     if (d>128)
  1739.         d=128;
  1740.  
  1741.     if (!just_scored && EUROmatch_info.freekicks && ((seed<d) || (see)))
  1742.     {
  1743.         incident_x=teams[fouler-1].tm_x;
  1744.         incident_y=teams[fouler-1].tm_y;
  1745.  
  1746.         direct_fk=direct;
  1747.          bad_guy=fouler;
  1748.  
  1749. // The referee sees the foul...
  1750.         if (offside_now)
  1751. // Cannot play advantage with offside rule...
  1752.             punish_foul(fouler,direct_fk);
  1753.         else
  1754.         {
  1755.             af_randomize();
  1756.  
  1757. // May play advantage...
  1758.             if (fouler<12)
  1759. // Team A commited foul...
  1760.             {
  1761.                 if ((!ball_poss) && (seed>ref_strictness))
  1762. // Ball is free...play temporary advantage...
  1763.                 {
  1764.                     play_advantage=TRUE;
  1765.                     init_speech(players+1,SAY_ADV);
  1766.                 }
  1767.                 else
  1768.                     if (ball_poss<12)
  1769.                         punish_foul(fouler,direct_fk);
  1770.             }
  1771.             else
  1772. // Team B commited foul...
  1773.             {
  1774.                 if ((!ball_poss) && (seed>ref_strictness))
  1775. // Ball is free...play temporary advantage...
  1776.                 {
  1777.                     play_advantage=TRUE;
  1778.                     init_speech(players+1,SAY_ADV);
  1779.                 }
  1780.                 else
  1781.                     if (ball_poss>11 || !ball_poss)
  1782.                         punish_foul(fouler,direct_fk);
  1783.  
  1784.             }
  1785.         }
  1786.     }
  1787.     else
  1788.     {
  1789.         if (seed&2 && !just_scored)
  1790.             PlayCommentaryMessage(FU_DIVE);
  1791.     }
  1792. }
  1793.  
  1794.  
  1795. /******************************************************************************
  1796. *****************************************************************************/
  1797.  
  1798. extern int pen_cnt;
  1799.  
  1800. void force_penalty()
  1801. {
  1802.     pen_cnt=100;
  1803.     holder_lose_ball();
  1804.     ball_poss=12;
  1805.     ballx=pitch_len-2;
  1806.     bally=cntspot_y;
  1807.     ballz=ball_diam/2;
  1808.     init_foul(13,TRUE,TRUE);
  1809. }
  1810.     
  1811. /******************************************************************************
  1812. *****************************************************************************/
  1813.  
  1814. void init_fkick()
  1815. {
  1816.     float x,y,d;
  1817.  
  1818.     if (last_touch<12)
  1819.         x=-ballx;
  1820.     else
  1821.         x=pitch_len-ballx;
  1822.     
  1823.     y=cntspot_y-bally;
  1824.     d=calc_dist(x,y);
  1825.     taker_x=ballx-(x*BESIDE_BALL/d);
  1826.     taker_y=bally-(y*BESIDE_BALL/d);
  1827.  
  1828. // Referee go to spot behind incident...
  1829.     refs[0].act=1;
  1830.     refs[0].target=0;    // Ball!
  1831.     float rx=refs[0].x-ballx;
  1832.     float ry=refs[0].y-bally;
  1833.     float rd=calc_dist(rx,ry);
  1834.     refs[0].goto_x=ballx+(rx*BESIDE_BALL*16/rd);
  1835.     refs[0].goto_y=bally+(ry*BESIDE_BALL*16/rd);
  1836.     main_man=fkick_taker;
  1837.     last_touch=fkick_taker;
  1838.     pre_kp_touch=last_touch;
  1839. }
  1840.  
  1841. /******************************************************************************
  1842. *****************************************************************************/
  1843.  
  1844. void find_wall_guys(int guys,float x,float y)
  1845. {
  1846.     int d,pn,min_d,wall_cnt;
  1847.     float dist=prat*0.9;
  1848.     float xd=x*dist;
  1849.     float yd=y*dist;
  1850.     float cx=wallx-xd;
  1851.     float cy=wally-yd;
  1852.  
  1853.     wall_cnt=0;
  1854.  
  1855.     for (int j=0; j<men_in_wall; j++)
  1856.     {
  1857.          min_d=2000;
  1858.         for (int i=guys; i<guys+10; i++)
  1859.         {
  1860.             if ((!teams[i-1].tm_wall) && (teams[i-1].guy_on>0))
  1861.             {
  1862.                 if (i<12)
  1863.                     d=calc_dist(ballx-match_tactics1[ball_zone1][i-2][0],
  1864.                                    bally-match_tactics1[ball_zone1][i-2][1]);
  1865.                 else
  1866.                     d=calc_dist((pitch_len-ballx)-match_tactics2[ball_zone2][i-13][0],
  1867.                                    (pitch_wid-bally)-match_tactics2[ball_zone2][i-13][1]);
  1868.  
  1869.                 if (d<min_d)
  1870.                 {
  1871.                     min_d=d;
  1872.                     pn=i;
  1873.                 }
  1874.             }
  1875.         }
  1876.         if (min_d!=2000)
  1877.         {
  1878. // found an idiot...
  1879.             teams[pn-1].tm_wall=TRUE;
  1880.             wguys[j].guy=pn;
  1881.             wguys[j].x=cx;
  1882.             wguys[j].y=cy;
  1883.             cx=cx+xd;
  1884.             cy=cy+yd;
  1885.             wall_cnt++;
  1886.         }
  1887.     }
  1888.     men_in_wall=wall_cnt;
  1889.  
  1890. // Get keeper position...
  1891.     float gx,gy;
  1892.     x=wguys[wall_cnt-2].x-incident_x;        // 2nd last man in wall!
  1893.     y=wguys[wall_cnt-2].y-incident_y;
  1894.     if (guys>11)
  1895. // Team B's goal...
  1896.         gx=pitch_len-prat;
  1897.     else
  1898. // Team A's goal...
  1899.         gx=0+prat;
  1900.     
  1901.     gx=gx-incident_x;
  1902.     gy=y*gx/x;
  1903.     
  1904.     keeper_pos_x=gx+incident_x;
  1905.     keeper_pos_y=gy+incident_y;
  1906.  
  1907. }
  1908.  
  1909. /*****************************************************************************
  1910. *****************************************************************************/
  1911.  
  1912. void inc_pfoul(short p)
  1913. {
  1914.     teams[p-1].tm_fouls+=10;        // add giving penalty to foul list.
  1915. }
  1916.  
  1917. /*****************************************************************************
  1918. *****************************************************************************/
  1919.  
  1920. void inc_dfoul(short p)
  1921. {
  1922.     teams[p-1].tm_fouls+=3;        // add direct F.K. to foul list.
  1923. }
  1924.  
  1925. /*****************************************************************************
  1926. *****************************************************************************/
  1927.  
  1928. void inc_ifoul(short p)
  1929. {
  1930.     teams[p-1].tm_fouls++;        // add indirect F.K. to foul list.
  1931. }
  1932.  
  1933. /*****************************************************************************
  1934. *****************************************************************************/
  1935.  
  1936. void inc_pass(short p)
  1937. {
  1938.     teams[p-1].tm_pass++;        // Passes attempted.
  1939. }
  1940.  
  1941. /*****************************************************************************
  1942. *****************************************************************************/
  1943.  
  1944. void inc_work(short p)
  1945. {
  1946.     teams[p-1].tm_work++;        // Passes attempted.
  1947. }
  1948.  
  1949. /******************************************************************************
  1950. *****************************************************************************/
  1951.  
  1952. void inc_pwon(short p)
  1953. {
  1954.     teams[p-1].tm_pwon++;        // Passes won.
  1955. }
  1956.  
  1957. /******************************************************************************
  1958. *****************************************************************************/
  1959.  
  1960. void inc_tack(short p)
  1961. {
  1962.     teams[p-1].tm_tacks++;        // Tackles attempted.
  1963. }
  1964.  
  1965. /******************************************************************************
  1966. *****************************************************************************/
  1967.  
  1968. void inc_twon(short p)
  1969. {
  1970.     teams[p-1].tm_twon++;        // Tackles won.
  1971. }
  1972.  
  1973. /******************************************************************************
  1974. *****************************************************************************/
  1975.  
  1976. void inc_poss(short p)
  1977. {
  1978.     teams[p-1].tm_posst++;        // Possession time.
  1979. }
  1980.  
  1981. /******************************************************************************
  1982. *****************************************************************************/
  1983.  
  1984. void inc_inj(short p,short i)
  1985. {
  1986.     teams[p-1].tm_inj+=i;        // Injury.
  1987. }
  1988.  
  1989. /******************************************************************************
  1990. *****************************************************************************/
  1991.  
  1992. void inc_yellow(short p)
  1993. {
  1994.     teams[p-1].tm_book++;        // Yellow card.
  1995. }
  1996.  
  1997. /******************************************************************************
  1998. *****************************************************************************/
  1999.  
  2000. void inc_red(short p)
  2001. {
  2002.     teams[p-1].tm_book+=5;        // Red card.
  2003. }
  2004.  
  2005. /******************************************************************************
  2006. *****************************************************************************/
  2007.  
  2008. void inc_shot(short p)
  2009. {
  2010.     teams[p-1].tm_shots++;        // Shots attempted.
  2011. }
  2012.  
  2013. /******************************************************************************
  2014. *****************************************************************************/
  2015.  
  2016. void inc_goal(short p)
  2017. {
  2018.     teams[p-1].tm_goals++;        // Goals scored.
  2019. }
  2020.  
  2021. /******************************************************************************
  2022. *****************************************************************************/
  2023.  
  2024. void inc_ogs(short p)
  2025. {
  2026.     teams[p-1].tm_ogs++;        // Own goals scored.
  2027. }
  2028.  
  2029. /******************************************************************************
  2030. *****************************************************************************/
  2031.  
  2032. void inc_save(short p)
  2033. {
  2034.     teams[p-1].tm_saved++;        // shots saved.
  2035. }
  2036.  
  2037. /******************************************************************************
  2038. *****************************************************************************/
  2039.  
  2040. void inc_saves(short p)
  2041. {
  2042.     teams[p-1].tm_kpsaves++;        // Saved shot.
  2043. }
  2044.  
  2045. /******************************************************************************
  2046. *****************************************************************************/
  2047.  
  2048. void add_comp_pass(short plr)
  2049. {
  2050.     if (last_touch && ((last_touch<12 && plr<12)
  2051.         || (last_touch>11 && plr>11)))
  2052.         inc_pwon(last_touch);
  2053. }
  2054.  
  2055. /******************************************************************************
  2056. *****************************************************************************/
  2057.  
  2058. void init_dfkick()
  2059. {
  2060.     comsetp=40;
  2061.  
  2062.     int taker;
  2063.     float d,x,y,range;
  2064.  
  2065.     if (!booking)
  2066.     {
  2067.         if (last_touch<12)
  2068.             do_direct_menu(team_b);
  2069.         else
  2070.             do_direct_menu(team_a);
  2071.     }
  2072.  
  2073.     if (last_touch<12)
  2074. // F.K. to Team B...
  2075.  
  2076.     {
  2077.         last_touch=12;        // Team B have possession...
  2078.         x=-ballx;
  2079.         y=cntspot_y-bally;
  2080.         d=calc_dist(x,y);
  2081.         taker_x=ballx-(x*BESIDE_BALL/d);
  2082.         taker_y=bally-(y*BESIDE_BALL/d);
  2083.  
  2084. // Referee go to spot behind incident...
  2085.         refs[0].act=1;
  2086.         refs[0].target=0;    // Ball!
  2087.         float rx=refs[0].x-ballx;
  2088.         float ry=refs[0].y-bally;
  2089.         float rd=calc_dist(rx,ry);
  2090.         refs[0].goto_x=ballx+(rx*BESIDE_BALL*16/rd);
  2091.         refs[0].goto_y=bally+(ry*BESIDE_BALL*16/rd);
  2092.  
  2093.         range=calc_dist(x,y);
  2094.         if (range>(MIN_SHOOT_DIST+((float)teams[fkick_taker-1].tm_pow*3)))
  2095. // Out of shooting range!
  2096.         {
  2097.             men_in_wall=0;        // No wall!
  2098.             taker=-1;
  2099.         }
  2100.         else
  2101. // In shooting range!
  2102.         {
  2103.             in_range=TRUE;
  2104.             if (incident_y<cntspot_y)
  2105. // Near post is top!
  2106.             {
  2107.                 y=top_post_y-incident_y;
  2108.                 range=calc_dist(incident_x,y);
  2109.             }
  2110.             else
  2111. // Near post is bottom!
  2112.             {
  2113.                 y=bot_post_y-incident_y;
  2114.                 range=calc_dist(incident_x,y);
  2115.             }
  2116.  
  2117.             y=y/range;                                            // horiz. vector to goal!
  2118.             x=-incident_x/range;
  2119.  
  2120.             men_in_wall=5.5-(ABS(y)*3);                    // Team A make wall.
  2121.             taker=fkick_taker;
  2122.             wallx=incident_x+(prat*10*x);
  2123.             wally=incident_y+(prat*10*y);                    // Wall coords...
  2124.             if (incident_y<cntspot_y)
  2125.                 x=-x;
  2126.             else
  2127.                 y=-y;
  2128.             find_wall_guys(2,y,x);            // x,y reversed for right angle!
  2129.             if (!player_on_off)
  2130.                 PlayCommentaryMessage(FU_WALL);
  2131.         }
  2132.     }
  2133.     else
  2134. // F.K. to Team A...
  2135.  
  2136.     {
  2137.         last_touch=1;        // Team A have possession...
  2138.         x=pitch_len-ballx;
  2139.         y=cntspot_y-bally;
  2140.         d=calc_dist(x,y);
  2141.         taker_x=incident_x-(x*BESIDE_BALL/d);
  2142.         taker_y=incident_y-(y*BESIDE_BALL/d);
  2143.  
  2144. // Referee go to spot behind incident...
  2145.         refs[0].act=1;
  2146.         refs[0].target=0;    // Ball!
  2147.         float rx=refs[0].x-ballx;
  2148.         float ry=refs[0].y-bally;
  2149.         float rd=calc_dist(rx,ry);
  2150.         refs[0].goto_x=ballx+(rx*BESIDE_BALL*16/rd);
  2151.         refs[0].goto_y=bally+(ry*BESIDE_BALL*16/rd);
  2152.  
  2153.         range=calc_dist(x,y);
  2154.         if (range>(MIN_SHOOT_DIST+((float)teams[fkick_taker-1].tm_pow*3)))
  2155. // Out of shooting range!
  2156.         {
  2157.             men_in_wall=0;        // No wall!
  2158.             taker=0;                // Anybody can take F.K.
  2159.         }
  2160.         else
  2161. // In shooting range!
  2162.         {
  2163.             in_range=TRUE;
  2164.             if (incident_y<cntspot_y)
  2165. // Near post is top!
  2166.             {
  2167.                 y=top_post_y-incident_y;
  2168.                 range=calc_dist(pitch_len-incident_x,y);
  2169.             }
  2170.             else
  2171. // Near post is bottom!
  2172.             {
  2173.                 y=bot_post_y-incident_y;
  2174.                 range=calc_dist(pitch_len-incident_x,y);
  2175.             }
  2176.  
  2177.             y=y/range;                                          // horiz. vector to goal!
  2178.             x=(pitch_len-incident_x)/range;
  2179.  
  2180.             men_in_wall=5.5-(ABS(y)*3);                // Team B make wall.
  2181.             taker=fkick_taker;
  2182.             wallx=incident_x+(prat*10*x);
  2183.             wally=incident_y+(prat*10*y);                // Wall coords...
  2184.             if (incident_y<cntspot_y)
  2185.                 y=-y;
  2186.             else
  2187.                 x=-x;
  2188.             find_wall_guys(13,y,x);            // x,y reversed for right angle!
  2189.             if (!player_on_off)
  2190.                 PlayCommentaryMessage(FU_WALL);
  2191.         }
  2192.     }
  2193.  
  2194.     if (taker<1)
  2195. // Not close enough to take shot so nearest can take!
  2196.     {
  2197.         int min_d=1000;
  2198.         int d;
  2199.         int p=(taker<0 ? 13:2);
  2200.  
  2201.         for (int pn=p; pn<p+10; pn++)
  2202.         {
  2203.             if (teams[pn-1].guy_on>0)
  2204.             {
  2205.                 if (pn<12)
  2206.                     d=calc_dist(ballx-match_tactics1[ball_zone1][pn-2][0],
  2207.                                    bally-match_tactics1[ball_zone1][pn-2][1]);
  2208.                 else
  2209.                     d=calc_dist((pitch_len-ballx)-match_tactics2[ball_zone2][pn-13][0],
  2210.                                    (pitch_wid-bally)-match_tactics2[ball_zone2][pn-13][1]);
  2211.  
  2212.                 if (d<min_d)
  2213.                 {
  2214.                     min_d=d;
  2215.                     fkick_taker=pn;
  2216.                 }
  2217.             }
  2218.         }
  2219.     }
  2220.  
  2221.     main_man=fkick_taker;
  2222.     last_touch=fkick_taker;
  2223.     pre_kp_touch=last_touch;
  2224. }
  2225.  
  2226. /******************************************************************************
  2227. *****************************************************************************/
  2228.  
  2229. void init_penalty()
  2230. {
  2231.     if (!penalty_game)
  2232.         PlayCommentaryMessage(SP_PENALTY);
  2233.  
  2234.     float x,y,range;
  2235.  
  2236.     if (match_mode==PEN_KICK_A)
  2237.     {
  2238.         ballx=pitch_len-(prat*12);
  2239. #ifdef EURO96
  2240.         taker_x=ballx-PEN_RUNUP_DIST;
  2241. #else
  2242.         taker_x=ballx-8;
  2243. #endif
  2244.     }
  2245.     else
  2246.     {
  2247.         ballx=(prat*12);
  2248. #ifdef EURO96
  2249.         taker_x=ballx+PEN_RUNUP_DIST;
  2250. #else
  2251.         taker_x=ballx+8;
  2252. #endif
  2253.     }
  2254.  
  2255.     taker_y=cntspot_y;
  2256.     bally=cntspot_y;
  2257.     incident_x=ballx;
  2258.     incident_y=bally;
  2259.  
  2260. // Referee go to spot above penalty spot...
  2261.     refs[0].act=1;
  2262.     refs[0].target=0;    // Ball!
  2263.     refs[0].goto_x=ballx;
  2264.     refs[0].goto_y=cntspot_y-(prat*10);
  2265.  
  2266.     if ((!penalty_taker) || (!teams[penalty_taker-1].guy_on))
  2267. // No particular player chosen nearest can take!
  2268.     {
  2269.         int min_d=1000;
  2270.         int d;
  2271.         int p=(match_mode==PEN_KICK_B ? 13:2);
  2272.  
  2273.         for (int pn=p; pn<p+10; pn++)
  2274.         {
  2275.             if (pn<12)
  2276.                 d=calc_dist(ballx-match_tactics1[ball_zone1][pn-2][0],
  2277.                                bally-match_tactics1[ball_zone1][pn-2][1]);
  2278.             else
  2279.                 d=calc_dist((pitch_len-ballx)-match_tactics2[ball_zone2][pn-13][0],
  2280.                                (pitch_wid-bally)-match_tactics2[ball_zone2][pn-13][1]);
  2281.  
  2282.             if (d<min_d)
  2283.             {
  2284.                 min_d=d;
  2285.                 penalty_taker=pn;
  2286.             }
  2287.         }
  2288.     }
  2289.  
  2290.     main_man=penalty_taker;
  2291. /*
  2292.     if (main_man<12)
  2293.     {
  2294. // Team A penalty...
  2295.         user_keeper_b();
  2296.     }
  2297.     else        
  2298.     {
  2299. // Team B penalty...
  2300.         user_keeper_a();
  2301.     }
  2302. */
  2303. }
  2304.  
  2305. /******************************************************************************
  2306. *****************************************************************************/
  2307.  
  2308. void init_match_mode()
  2309. {
  2310.     ref_wait=(160-ref_strictness)*REAL_SPEED/8;
  2311.     support_me=FALSE;
  2312.     spec_kick_type=0;
  2313.     already_there=FALSE;        // Taker is not in position.
  2314.     reselection=FALSE;        // When do I reselect auto users.
  2315.     clear_all_autos();        // Clear all auto selected players.
  2316.  
  2317.     if (match_mode)
  2318.     {
  2319.         play_advantage=FALSE;
  2320.         setp_wait_cnt=MAX_SETP_WAIT;
  2321.         if (ball_limbo_on)
  2322.         {
  2323.             ball_limbo_on=FALSE;
  2324.             teams[ball_limbo_p-1].tm_limbo=FALSE;
  2325.         }
  2326.         teams[KP_A-1].tm_limbo=0;
  2327.         teams[KP_B-1].tm_limbo=0;
  2328.  
  2329.  
  2330.         reset_all_ideas();
  2331.         holder_lose_ball();
  2332.         if (teams[KP_A-1].tm_act==KPHOLD_ACT)
  2333.             init_stand_act(&teams[KP_A-1]);
  2334.  
  2335.         if (teams[KP_B-1].tm_act==KPHOLD_ACT)
  2336.             init_stand_act(&teams[KP_B-1]);
  2337.     }
  2338.  
  2339.     switch(match_mode)
  2340.     {
  2341.  
  2342. // Normal Play.
  2343.         case(0):
  2344.             break;
  2345.  
  2346. // Corner.
  2347.         case(CORNER_TL):
  2348.         case(CORNER_BL):
  2349.         case(CORNER_TR):
  2350.         case(CORNER_BR):
  2351.             set_piece_on=SETP_CORNER;
  2352.             can_be_offside=FALSE;
  2353.             play_fx(PS_SHORTWHISTLE,refs[0].x,refs[0].y);
  2354.             init_corner();
  2355.             break;
  2356.  
  2357. // Centre.
  2358.         case(CENTRE_A):
  2359.             if (!team_a_on)
  2360.                 match_mode=CENTRE_B;
  2361.         case(CENTRE_B):
  2362.             if (!team_b_on)
  2363.                 match_mode=CENTRE_A;
  2364.             set_piece_on=SETP_CENTRE;
  2365.             can_be_offside=TRUE;
  2366.             play_fx(PS_SHORTWHISTLE,refs[0].x,refs[0].y);
  2367.             init_centre();
  2368.             break;
  2369.  
  2370. // Goal kick.
  2371.         case(GOAL_KICK_TL):
  2372.         case(GOAL_KICK_BL):
  2373.         case(GOAL_KICK_TR):
  2374.         case(GOAL_KICK_BR):
  2375.             set_piece_on=SETP_GKICK;
  2376.             can_be_offside=FALSE;
  2377.             play_fx(PS_SHORTWHISTLE,refs[0].x,refs[0].y);
  2378.             init_gkick();
  2379.             break;
  2380.  
  2381. // Throw in.
  2382.         case(THROW_IN_A):
  2383.         case(THROW_IN_B):
  2384.             set_piece_on=SETP_THROW;
  2385.             can_be_offside=FALSE;
  2386.             play_fx(PS_SHORTWHISTLE,refs[0].x,refs[0].y);
  2387.             init_throw();
  2388.             break;
  2389.  
  2390. // Indirect free kick.
  2391.         case(IF_KICK_A):
  2392.             if (!team_a_on)
  2393.                 match_mode=IF_KICK_B;
  2394.         case(IF_KICK_B):
  2395.             if (!team_b_on)
  2396.                 match_mode=IF_KICK_A;
  2397.             can_be_offside=TRUE;
  2398.             play_fx(PS_LONGWHISTLE,refs[0].x,refs[0].y);
  2399.             set_piece_on=SETP_IFKICK;
  2400.             init_fkick();
  2401.             break;
  2402.  
  2403. // Direct free kick.
  2404.         case(DF_KICK_A):
  2405.             if (!team_a_on)
  2406.                 match_mode=DF_KICK_B;
  2407.         case(DF_KICK_B):
  2408.             if (!team_b_on)
  2409.                 match_mode=DF_KICK_A;
  2410.             can_be_offside=TRUE;
  2411.             play_fx(PS_LONGWHISTLE,refs[0].x,refs[0].y);
  2412.             set_piece_on=SETP_DFKICK;
  2413.             init_dfkick();
  2414.             break;
  2415.  
  2416. // Penalty kick.
  2417.         case(PEN_KICK_A):
  2418.             if (!team_a_on)
  2419.                 match_mode=PEN_KICK_B;
  2420.         case(PEN_KICK_B):
  2421.             if (!team_b_on)
  2422.                 match_mode=PEN_KICK_A;
  2423.             can_be_offside=FALSE;
  2424.             play_fx(PS_LONGWHISTLE,refs[0].x,refs[0].y);
  2425.             set_piece_on=SETP_PENALTY;
  2426.             init_penalty();
  2427.             break;
  2428.  
  2429.         case(SWAP_ENDS):
  2430.             init_swap_ends();
  2431.             break;
  2432.  
  2433.     }
  2434.     setp_taker=main_man;
  2435. }
  2436.  
  2437. /******************************************************************************
  2438. *****************************************************************************/
  2439.  
  2440. char offc_thinking()
  2441. {
  2442.     int f=((129-ref_accuracy)/4)+1;
  2443.     int t=logic_cnt/f;
  2444.     int r=logic_cnt-(t*f);
  2445.     return(!r);
  2446. }
  2447.  
  2448. /******************************************************************************
  2449. *****************************************************************************/
  2450.  
  2451. void init_ref_stand(officials *lman)
  2452. {
  2453.     if (ABS(lman->anim)!=MC_STAND)
  2454.     {
  2455.         lman->anim=MC_STAND;
  2456.         lman->newanim=TRUE;
  2457.         lman->frm=0;
  2458.         lman->fstep=MC_STAND_FS;
  2459.     }
  2460. }
  2461.  
  2462. /******************************************************************************
  2463. *****************************************************************************/
  2464.  
  2465. void init_ref_run(officials *lman)
  2466. {
  2467.     if (ABS(lman->anim)==MC_JOG)
  2468.     {
  2469. // Tween to run from jog....
  2470.         lman->anim=MC_RUN;
  2471.         lman->fstep=MC_RUN_FS;
  2472.     }
  2473.     else
  2474.         if (ABS(lman->anim)!=MC_RUN)
  2475.         {
  2476.             lman->anim=MC_RUN;
  2477.             lman->newanim=TRUE;
  2478.             lman->frm=0;
  2479.             lman->fstep=MC_RUN_FS;
  2480.         }
  2481. }
  2482.  
  2483. /******************************************************************************
  2484. *****************************************************************************/
  2485.  
  2486. void init_ref_jog(officials *lman)
  2487. {
  2488.     if (ABS(lman->anim)==MC_RUN)
  2489.     {
  2490. // Tween to jog from run....
  2491.         lman->anim=MC_JOG;
  2492.         lman->fstep=MC_JOG_FS;
  2493.     }
  2494.     else
  2495.         if (ABS(lman->anim)!=MC_JOG)
  2496.         {
  2497.             lman->anim=MC_JOG;
  2498.             lman->newanim=TRUE;
  2499.             lman->frm=0;
  2500.             lman->fstep=MC_JOG_FS;
  2501.         }
  2502. }
  2503.  
  2504. /******************************************************************************
  2505. *****************************************************************************/
  2506.  
  2507. void init_rtrot_anim(officials *lman)
  2508. {
  2509.     float x=lman->goto_x-lman->x;
  2510.     float y=lman->goto_y-lman->y;
  2511.  
  2512.     float d=calc_dist(x,y);
  2513.  
  2514.     lman->fstep=MC_TROTA_FS;
  2515.  
  2516.     x=x/d;
  2517.     y=y/d;
  2518.  
  2519.     float nx=(x*lman->dir_x)+(y*lman->dir_y);
  2520.     float ny=(y*lman->dir_x)-(x*lman->dir_y);
  2521.  
  2522.     if (lman->anim<MC_TROTB || lman->anim>MC_TROTE)
  2523. // Not currently in trot animation...
  2524.     {
  2525.         lman->frm=0;
  2526.         lman->newanim=TRUE;
  2527.     }
  2528.     
  2529.     switch((1+get_dir(nx,ny)))
  2530.     {
  2531.         case(8):
  2532.             lman->anim=MC_TROTF;
  2533.             break;
  2534.  
  2535.         case(7):
  2536.             lman->anim=MC_TROTG;
  2537.             break;
  2538.  
  2539.         case(6):
  2540.             lman->anim=MC_TROTH;
  2541.             break;
  2542.  
  2543.         case(5):
  2544.             lman->anim=MC_TROTA;
  2545.             break;
  2546.  
  2547.         case(4):
  2548.             lman->anim=MC_TROTB;
  2549.             break;
  2550.  
  2551.         case(3):
  2552.             lman->anim=MC_TROTC;
  2553.             break;
  2554.  
  2555.         case(2):
  2556.             lman->anim=MC_TROTD;
  2557.             break;
  2558.  
  2559.         case(1):
  2560.             lman->anim=MC_TROTE;
  2561.             break;
  2562.     }
  2563. }
  2564.  
  2565. /******************************************************************************
  2566. *****************************************************************************/
  2567.  
  2568. void init_refs_anim(officials *lman,int an)
  2569. {
  2570.     switch(an)
  2571.     {
  2572.         case(MC_STAND):
  2573.             init_ref_stand(lman);
  2574.             break;
  2575.  
  2576.         case(MC_RUN):
  2577.             init_ref_run(lman);
  2578.             break;
  2579.  
  2580.         case(MC_JOG):
  2581.             init_ref_jog(lman);
  2582.             break;
  2583.  
  2584.         case(MC_TROTA):
  2585.             init_rtrot_anim(lman);
  2586.             break;
  2587.     }
  2588. }
  2589.  
  2590. /******************************************************************************
  2591. *****************************************************************************/
  2592.  
  2593. void lman_follow(officials *lman)
  2594. {
  2595.     if (match_mode)
  2596.     {
  2597.         init_refs_anim(lman,MC_STAND);
  2598.         lman->go=12+(129-ref_accuracy)/4;
  2599.     }
  2600.     else
  2601.     {
  2602.         float x;
  2603.         if (lman->go>0)
  2604.             lman->go--;
  2605.         else
  2606.         {
  2607.             if (lman->y<cntspot_y)
  2608. // Top Linesman...
  2609.             {
  2610.                 lman->dir_x=0;
  2611.                 lman->dir_y=1;
  2612.  
  2613.                 if (ballx>cntspot_x)
  2614.                     x=((ballx-defense_a)/1.25)*(pitch_wid-bally)/pitch_wid;
  2615.                 else
  2616.                     x=0;
  2617.  
  2618.                 if (defense_a+x-2>lman->x)
  2619.                 {
  2620.                     lman->goto_x=lman->x+2;
  2621.                     if (lman->anim!=MC_TROTG)
  2622.                         init_refs_anim(lman,MC_TROTA);
  2623.                     lman->x=lman->goto_x;
  2624.                 }
  2625.                 else
  2626.                     if (defense_a+x+2<lman->x)
  2627.                     {
  2628.                         lman->goto_x=lman->x-2;
  2629.                         if (lman->anim!=MC_TROTC)
  2630.                             init_refs_anim(lman,MC_TROTA);
  2631.                         lman->x=lman->goto_x;
  2632.                     }
  2633.                     else
  2634.                     {
  2635.                         init_refs_anim(lman,MC_STAND);
  2636.                         lman->go=12+(129-ref_accuracy)/4;
  2637.                     }
  2638.             }
  2639.             else
  2640.             {
  2641. // Bot. Linesman...
  2642.                 lman->dir_x=0;
  2643.                 lman->dir_y=-1;
  2644.  
  2645.                 if (ballx<cntspot_x)
  2646.                     x=((defense_b-ballx)/1.25)*bally/pitch_wid;
  2647.                 else
  2648.                     x=0;
  2649.  
  2650.                 if (defense_b+x-2>lman->x)
  2651.                 {
  2652.                     lman->goto_x=lman->x+2;
  2653.                     if (lman->anim!=MC_TROTC)
  2654.                         init_refs_anim(lman,MC_TROTA);
  2655.                     lman->x=lman->goto_x;
  2656.                 }
  2657.                 else
  2658.                     if (defense_b+x+2<lman->x)
  2659.                     {
  2660.                         lman->goto_x=lman->x-2;
  2661.                         if (lman->anim!=MC_TROTG)
  2662.                             init_refs_anim(lman,MC_TROTA);
  2663.                         lman->x=lman->goto_x;
  2664.                     }
  2665.                     else
  2666.                     {
  2667.                         init_refs_anim(lman,MC_STAND);
  2668.                         lman->go=12+(129-ref_accuracy)/4;
  2669.                     }
  2670.             }
  2671.         }
  2672.     }
  2673. }
  2674.  
  2675. /******************************************************************************
  2676. *****************************************************************************/
  2677.  
  2678. void await_kicker(officials *offc)
  2679. {
  2680.     init_refs_anim(&refs[0],MC_STAND);
  2681.  
  2682.     if ((!match_mode) && (teams[ktaker-1].tm_act!=THROW_ACT))
  2683.         offc->act=0;
  2684.     else
  2685.     {
  2686.         if (!(--ref_wait) && match_mode!=PEN_KICK_A && match_mode!=PEN_KICK_B)
  2687.         {
  2688. // Time-up!!!
  2689. #ifdef STOP_TIME_WASTING
  2690.             if (!practice)
  2691. #else
  2692.             if (!practice && teams[ktaker-1].tm_act!=THROW_ACT)
  2693. #endif
  2694.             {
  2695.                 ref_wait=-1;
  2696. // Cannot be in practice mode...
  2697.                 if (teams[ktaker-1].tm_act==THROW_ACT)
  2698.                 {
  2699. // Give away a throw...
  2700.                     if (ktaker>11)
  2701. // Team A gets Throw In...
  2702.                     {
  2703.                         match_mode=THROW_IN_A;
  2704.                         init_match_mode();
  2705.                         init_stand_act(&teams[ktaker-1]);
  2706.                         holder_lose_ball();
  2707.                     }
  2708.                     else
  2709. // Team B gets Throw In...
  2710.                     {
  2711.                         match_mode=THROW_IN_B;
  2712.                         init_match_mode();
  2713.                         init_stand_act(&teams[ktaker-1]);
  2714.                         holder_lose_ball();
  2715.                     }
  2716.                 }
  2717. /*
  2718.                 else
  2719.                 {
  2720.                     if ((match_mode>=CORNER_TL) && (match_mode<=CORNER_BR))
  2721.                     {
  2722. // Give opposing team a Goal Kick...
  2723.                         match_mode+=6;
  2724.                         init_match_mode();
  2725.                         init_stand_act(&teams[setp_taker-1]);
  2726.                         holder_lose_ball();
  2727.                     }
  2728.                     else
  2729.                     {
  2730. // Opposing Team recieves Indirect Free Kick...
  2731.                         init_foul(ktaker,FALSE,TRUE);
  2732.                         init_stand_act(&teams[setp_taker-1]);
  2733.                         holder_lose_ball();
  2734.                     }
  2735.                 }
  2736.                 init_speech(players+1,SAY_TIMEW);
  2737. */
  2738.             }
  2739.         }
  2740.     }
  2741. }
  2742.  
  2743. /******************************************************************************
  2744. *****************************************************************************/
  2745.  
  2746. void goto_target(officials *offc)
  2747. {
  2748.     float tx,ty,x,y,d,bd,nx,ny,ox,oy,dif,spd;
  2749.  
  2750.     tx=offc->goto_x-offc->x;
  2751.     ty=offc->goto_y-offc->y;
  2752.  
  2753.     d=calc_dist(tx,ty);
  2754.     tx=tx/d;
  2755.     ty=ty/d;
  2756.  
  2757.     offc->dir_x=tx;
  2758.     offc->dir_y=ty;
  2759.  
  2760.     if (d>2.6)
  2761. // Not there yet...
  2762.     {
  2763.         init_refs_anim(offc,MC_JOG);
  2764.         spd=2.6;
  2765.     }
  2766.     else
  2767.     {
  2768.         init_refs_anim(offc,MC_STAND);
  2769.         offc->act=3;    // Face target!
  2770.         spd=0;
  2771.     }
  2772.  
  2773.     offc->x+=tx*spd;
  2774.       offc->y+=ty*spd;
  2775. }
  2776.  
  2777. /******************************************************************************
  2778. *****************************************************************************/
  2779.  
  2780. void at_target(officials *referee)
  2781. {
  2782. // Turns player to face object (ball or player!)
  2783.  
  2784.     float nx,ny,x,y,bd,xd,yd,dif;
  2785.     float max=(PI/12);
  2786.  
  2787.     if (!referee->target)
  2788.     {
  2789. // Face ball!
  2790.         x=ballx-referee->x;
  2791.         y=bally-referee->y;
  2792.     }
  2793.     else
  2794.     {
  2795. // Face Player!
  2796.         x=teams[referee->target-1].tm_x-referee->x;
  2797.         y=teams[referee->target-1].tm_x-referee->y;
  2798.     }
  2799.  
  2800.     bd=calc_dist(x,y);
  2801.  
  2802.     x=x/bd;
  2803.     y=y/bd;
  2804.  
  2805.     xd=referee->dir_x;
  2806.     yd=referee->dir_y;
  2807.  
  2808.     dif=((x*xd)+(y*yd));
  2809.  
  2810.     if (dif<cos(max))
  2811.     {
  2812.         if ((x*yd)>(y*xd))
  2813.             max=-max;
  2814.  
  2815.         nx=(xd*cos(max))-(yd*sin(max));
  2816.         ny=(yd*cos(max))+(xd*sin(max));
  2817.     }
  2818.     else
  2819.     {
  2820.         nx=x;
  2821.         ny=y;
  2822.         referee->act=4;        // Action complete!
  2823.     }
  2824.  
  2825.     bd=calc_dist(nx,ny);
  2826.     nx=nx/bd;
  2827.     ny=ny/bd;
  2828.  
  2829.     referee->dir_x=nx;
  2830.     referee->dir_y=ny;
  2831. }
  2832.  
  2833. /******************************************************************************
  2834. *****************************************************************************/
  2835.  
  2836. void follow_play(officials *referee)
  2837. {
  2838.     float tx,ty,x,y,d,bd,nx,ny,ox,oy,dif,spd;
  2839.     if (!match_mode)
  2840.     {
  2841.         x=ballx-referee->x;
  2842.         y=bally-referee->y;
  2843.  
  2844.         bd=calc_dist(x,y);
  2845.  
  2846. // Face Ball...
  2847.         if (bd>0.2)
  2848.         {
  2849.             referee->dir_x=x/bd;
  2850.             referee->dir_y=y/bd;
  2851.         }
  2852.  
  2853.         tx=cntspot_x+((ballx-cntspot_x)*0.5)+((last_touch<12) ? (prat*10):(prat*-10));
  2854.         ty=cntspot_y+((bally-cntspot_y)*0.5);
  2855.  
  2856.         tx=tx-referee->x;
  2857.         ty=ty-referee->y;
  2858.  
  2859.         d=calc_dist(tx,ty);
  2860.  
  2861.         if (d>prat*2)
  2862.         {
  2863.  
  2864. // Keep distance from ball..
  2865.             if ((bd>0.2) && (bd<prat*10) && (!dead_ball_cnt))
  2866.             {
  2867.                 tx-=x*50/bd;
  2868.                 ty-=y*50/bd;
  2869.                 d=calc_dist(tx,ty);
  2870.             }
  2871.  
  2872.             if (d>prat*2)
  2873.             {
  2874.                 referee->goto_x=referee->x+tx;
  2875.                 referee->goto_y=referee->y+ty;
  2876.  
  2877.                 tx=tx/d;
  2878.                 ty=ty/d;
  2879.  
  2880. // Get angle of movement Vs facing...
  2881.                 dif=((referee->dir_x*tx)+(referee->dir_y*ty));
  2882.                 if (dif>1.0)
  2883.                     dif=1;
  2884.  
  2885.                 if (dif<-1.0)
  2886.                     dif=-1;
  2887.  
  2888.                 init_refs_anim(&refs[0],MC_TROTA);
  2889.                 spd=2.2;
  2890.  
  2891.                 referee->x+=tx*spd;
  2892.                 referee->y+=ty*spd;
  2893.         
  2894.             }
  2895.             else
  2896.             {
  2897.                     init_refs_anim(&refs[0],MC_STAND);
  2898.             }
  2899.         }
  2900.         else
  2901.         {
  2902.             init_refs_anim(&refs[0],MC_STAND);
  2903.         }
  2904.     }
  2905. }
  2906.  
  2907. /******************************************************************************
  2908. *****************************************************************************/
  2909.  
  2910. void process_ref(officials *offc)
  2911. {
  2912.     if (match_mode==SWAP_ENDS)
  2913.         init_refs_anim(&refs[0],MC_STAND);
  2914.     else
  2915.     {
  2916.  
  2917.         switch(offc->act)
  2918.         {
  2919.             case(0):                // Follow Play...
  2920.                 follow_play(offc);
  2921.                 break;
  2922.  
  2923.             case(1):                // Goto target..
  2924.                 goto_target(offc);
  2925.                 break;
  2926.  
  2927.             case(2):                // Wait for someone to kick ball..
  2928.                 await_kicker(offc);
  2929.                 break;
  2930.  
  2931.             case(3):                // Stand and turn...
  2932.                 at_target(offc);
  2933.                 break;
  2934.  
  2935.             case(4):                // Facing target now...
  2936.                 at_target(offc);
  2937.                 break;
  2938.         }
  2939.     }
  2940. }
  2941.  
  2942. /******************************************************************************
  2943. *****************************************************************************/
  2944.  
  2945. void process_lman(officials *offc)
  2946. {
  2947.     switch(offc->act)
  2948.     {
  2949.         case(0):                // Follow Play...
  2950.             lman_follow(offc);
  2951.             break;
  2952.  
  2953.         case(1):                // Follow Play...
  2954.             goto_target(offc);
  2955.             break;
  2956.     }
  2957. }
  2958.  
  2959. /******************************************************************************
  2960. *****************************************************************************/
  2961.  
  2962. void anim_officials(officials *offc)
  2963. {
  2964.     offc->frm+=offc->fstep;
  2965. }
  2966.  
  2967. /******************************************************************************
  2968. *****************************************************************************/
  2969.  
  2970. void process_offs()
  2971. {
  2972.     process_ref(&refs[0]);
  2973.     process_lman(&refs[1]);
  2974.     process_lman(&refs[2]);
  2975.     anim_officials(&refs[0]);
  2976.     anim_officials(&refs[1]);
  2977.     anim_officials(&refs[2]);
  2978. }
  2979.